package com.ityuxin.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ityuxin.common.PageResult;
import com.ityuxin.dao.CustomerMapper;
import com.ityuxin.domain.Customer;
import com.ityuxin.domain.ServiceItemlist;
import com.ityuxin.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: yyh
 * @Description:
 * @Date:Create：in 2021/4/3 15:49
 * @Modified By：
 */
@Service
public class CustomerServiceimpl implements CustomerService {

    @Autowired
    private CustomerMapper customerMapper;


    @Override
    public List<Customer> findAll() {
        List<Customer> list =  customerMapper.findAll();
        return list;
    }

    @Override
    public void deleteById(Integer id) {
        customerMapper.deleteById(id);
    }

    @Override
    public void addCustomer(Customer customer) {
        customerMapper.addCustomer(customer);
    }



    @Override
    public void updateCustomer(Customer customer) {
        customerMapper.updateCustomer(customer);
    }

    @Override
    public PageResult findPage(Integer currentPage, Integer pageSize, String queryString) {

        //定义页面大小和当前页码
        PageHelper.startPage(currentPage,pageSize);

        //条件查询
        List<Customer> list =  customerMapper.findAll();

        //将数据进行包装
        PageInfo pageInfo  = new PageInfo<Customer>(list);

        return  new PageResult(pageInfo.getTotal(),pageInfo.getList());
    }



    @Override
    public Customer findById(Integer id) {

       return customerMapper.findById(id);
    }
}
